package com.dgshanger.sanhxiaofeisc.mvp.model

import com.dgshanger.sanhxiaofeisc.common.AppApi
import com.dgshanger.sanhxiaofeisc.entity.NearbyItemEntity
import com.dgshanger.sanhxiaofeisc.entity.SearchHotEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.SearchContract
import com.xx.baseutilslibrary.network.rx.RxHelper
import com.xx.baseutilslibrary.network.rx.XxBaseHttpObserver

/**
 * Created by JacobHHH on 2018/5/4.
 */
class SearchModel : SearchContract.Model {

    override fun search(location_name: String?, user_longitude: String?, user_latitude: String?,
                        shop_name: String?, httpObserver: XxBaseHttpObserver<MutableList<NearbyItemEntity>>?) {

        AppApi.Api().getHomeSearchResultData(location_name,user_longitude,user_latitude,shop_name)
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }

    override fun loadHotData(httpObserver: XxBaseHttpObserver<MutableList<SearchHotEntity>>?) {
        AppApi.Api().searchHotData
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }
}